#define _CRT_SECURE_NO_WARNINGS 1
#include"contact.h"

void menu()
{
	printf("=============================================\n");
	printf("===========1. add     2. del     ============\n");
	printf("===========3. search  4. modiy   ============\n");
	printf("===========5. show    6. sort    ============\n");
	printf("==============  0. exit  ====================\n");
	printf("=============================================\n");
}

void test()
{
	int input = 0;

	AddressBook con;

	InitAddressBook(&con);

	do
	{
		menu();
		printf("Please choose:>");
		scanf("%d", &input);

		switch (input)
		{
		case ADD:
			AddInfo(&con);
			break;
		case DEL:
			delInfo(&con);
			break;
		case SEARCH:
			SearchInfo(&con);
			break;
		case MODIFY:
			ModifyInfo(&con);
			break;
		case SHOW:
			showAddressBook(&con);
			break;
		case SORT:
			printf("Sorting... ...\n");
			Sleep(5000);
			SortInfo(&con);
			break;
		case EXIT:
			SaveData(&con);
			FreeMemory(&con);
			printf("You are going to exit this program, please press any key to confirm:>");
			getchar();
			getchar();
			break;
		default:
			printf("Invalid input! Please choose again!");
			break;
		}
		
	} while (input);
}

int main()
{
	test();

	return 0;
}